﻿using System;
using System.Collections.Generic;
using System.Linq;
using XcoAppSpaces.Core.Ports.Remoting;

namespace XcoAppSpaces.Core.Ports
{
	/// <summary>
	/// Extension methods for easier access to remote port information.
	/// </summary>
	public static class RemotablePortExtensions
	{
		/// <summary>
		/// Returns true, if the port is a remote port.
		/// </summary>
		/// <param name="port">The port.</param>
		/// <returns>True if the port is a remote port.</returns>
		public static bool IsRemotePort(this IRemotablePort port)
		{
			return (port.RemotePortInfo != null && port.RemotePortInfo.IsRemotePort);
		}

		/// <summary>
		/// Returns an object with remote port information for this port. (e.g. remote address)
		/// </summary>
		/// <param name="port">The port.</param>
		/// <returns>An object with remote port information for this port.</returns>
		public static XcoPortInfo GetPortInfo(this IRemotablePort port)
		{
			return port.RemotePortInfo ?? new XcoPortInfo(false, null, null, Guid.Empty);
		}
	}
}
